function RobotMovie  
    persistent pic_num;
    if isempty(pic_num)
        pic_num = 1;
    end
    drawnow;
    F=getframe(gcf)
    I=frame2im(F);
    [I,map]=rgb2ind(I,256);
    if pic_num == 1
        imwrite(I,map,'RobotMovie.gif','gif','Loopcount',inf,'DelayTime',0.2);
    else
        imwrite(I,map,'RobotMovie.gif','gif','WriteMode','append','DelayTime',0.2);
    end
    pic_num=pic_num+1;
end